﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MercuryFE
{
    public class InputDeviceState
    {

        public bool Up { get; set; }
        public bool Down { get; set; }
        public bool Left { get; set; }
        public bool Right { get; set; }

        public bool Select { get; set; }
        public bool Back { get; set; }
        public bool Info { get; set; }

        public string RawValue { get; set; }

        public string InterfaceType { get; set; } // KB, JS or MS

        public bool[] Buttons { get; set; }
        //public string Value { get; set; }

        public InputDeviceState()
        {
            Up = false;
            Down = false;
            Left = false;
            Right = false;
            Buttons = new bool[32];
            for(int i = 0; i < Buttons.Length; i++)
            {
                Buttons[i] = false;
            }
            //Value = null;
        }

        public void SetValue(string Key) {
            switch (Key)
            {
                case "Up": Up = true; break;
                case "Down": Down = true; break;
                case "Left": Left = true; break;
                case "Right": Right = true; break;
                case "Select": Select = true; break;
                case "Back": Back = true; break;
                case "Info": Info = true; break;


            }

        }


        public bool HasValue()
        {
            bool hasValue = false;

            if (Up || Down || Left || Right || Select || Right || Back || Info)
                hasValue = true;

            return hasValue;
        }

        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();
            if (Up)
                buffer.Append(" Up ");
            if (Down)
                buffer.Append(" Down ");
            if (Left)
                buffer.Append(" Left ");
            if (Right)
                buffer.Append(" Right ");
            if (Select)
                buffer.Append(" Select ");
            if (Back)
                buffer.Append(" Back ");
            if (Info)
                buffer.Append(" Info ");
            //if (Value != null && Value.Trim() != "")
            //    buffer.Append(" " + Value + " ");

            //for (int i = 0; i < Buttons.Length; i++)
            //{
            //    if (Buttons[i])
            //    {
            //        buffer.Append(" button" + (i + 1).ToString() + " ");
            //    }
            //}

            return buffer.ToString();
        }
    }
}
